package com.atguigu.spzx.product.service.impl;

import com.atguigu.spzx.common.utils.BeanUtils;
import com.atguigu.spzx.product.entity.Brand;
import com.atguigu.spzx.product.mapper.BrandMapper;
import com.atguigu.spzx.product.service.BrandService;
import com.atguigu.spzx.product.vo.BrandQueryRespVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * BrandServiceImpl
 * </p>
 *
 * @author flyduck
 * @since 2023/11/3
 */
@Service
public class BrandServiceImpl implements BrandService {

    @Autowired
    private BrandMapper brandMapper;

    /**
     * 获取全部品牌
     * @return
     */
    @Cacheable(value = "brandList", unless="#result.size() == 0")
    @Override
    public List<BrandQueryRespVo> findBrandList() {
        List<Brand> list = brandMapper.selectList(null);
        return BeanUtils.toBeanList(list,BrandQueryRespVo.class);
    }
}
